Sums of Squares
Introduction
- Many numbers can be written as a sum of squares, such as
- $5 = 1^2 + 2^2$
- $25 = 3^2 + 4^2$
- Others cannot, such as $3$ or $7$.
- This article explores:
- Which numbers can be written as a sum of two squares
- Why some numbers cannot
- Why every number can be written as a sum of four squares
- Along the way, we’ll see patterns, geometry, and a bit of number theory.
What Does It Mean to Be a Sum of Squares?
- A number $n$ is a sum of two squares if $$n = a^2 + b^2$$ for some whole numbers $a$ and $b$.
- A number is a sum of four squares if $$n = a^2 + b^2 + c^2 + d^2.$$
- We usually allow $0^2$ as a square.
- Examples:
- $1 = 1^2 + 0^2$
- $2 = 1^2 + 1^2$
- $50 = 1^2 + 7^2$
Geometric Intuition: Distances and the Plane
- The expression $a^2 + b^2$ appears naturally in geometry:
- It is the square of the distance from $(0,0)$ to $(a,b)$.
- Thinking geometrically:
- A number is a sum of two squares if it is the squared distance to some lattice point.
- Visual intuition:
- Points with integer coordinates form a grid.
- We are asking: Which distances from the origin land exactly on a grid point?
Exploring Small Examples
Try listing numbers and checking whether they are sums of two squares:
- $1 = 1^2 + 0^2$
- $2 = 1^2 + 1^2$
- $3$ — no combination of squares works
- $4 = 2^2 + 0^2$
- $5 = 1^2 + 2^2$
- $6$ — no combination works
- $7$ — no combination works
- $8 = 2^2 + 2^2$
- $9 = 3^2 + 0^2$
- $10 = 1^2 + 3^2$
Patterns begin to appear, but they’re subtle.
Patterns Begin to Emerge
Observations from small numbers:
- Many numbers of the form $4k+1$ work (e.g., $5, 13, 17$).
- Many numbers of the form $4k+3$ do not work (e.g., $3, 7, 11$).
- But there are exceptions, so we need a deeper rule.
- Multiplying sums of squares often gives another sum of squares:
- If $m = a^2 + b^2$ and $n = c^2 + d^2$, then $$mn = (a^2 + b^2)(c^2 + d^2).$$
- Which is equivalent to: $$mn = (ac - bd)^2 + (ad + bc)^2.$$
This multiplication property is a major clue.
Prime Numbers and Sums of Two Squares
Prime numbers behave in a very structured way:
- Some primes are themselves sums of two squares:
- $5 = 1^2 + 2^2$
- $13 = 2^2 + 3^2$
- Others are not:
- $3, 7, 11, 19$ cannot be written as $a^2 + b^2$.
The key pattern:
- A prime $p$ is a sum of two squares exactly when $$p \equiv 1 \pmod{4}$$ or $$p = 2$$
Fermat’s Two‑Square Theorem
Fermat’s theorem states:
- A prime $p$ can be written as $a^2 + b^2$
if and only if $$p = 2 \quad \text{or} \quad p \equiv 1 \pmod{4}.$$
Key ideas (without proof):
- Primes of the form $4k+3$ have a property that prevents them from splitting into two squares.
- Primes of the form $4k+1$ behave differently and allow such representations.
Composite Numbers: Building Up from Primes
Once we know how primes behave, we can understand all numbers.
A composite number $n$ is a sum of two squares if and only if:
- In the prime factorization of $n$, every prime of the form $4k+3$ appears with an even exponent.
Example:
- $45 = 3^2 \cdot 5$
- The prime $3$ (which is $4k+3$) appears with exponent $2$ (even)
- So $45$ is a sum of two squares: $$45 = 3^2 + 6^2.$$
Why Some Numbers Fail to Be Sums of Two Squares
Numbers fail for a simple reason:
- If a prime $p \equiv 3 \pmod{4}$ appears with an odd exponent in $n$, then $n$ cannot be a sum of two squares.
Examples:
- $3$ fails because $3^1$ has odd exponent.
- $21 = 3 \cdot 7$ fails because both primes are $4k+3$ and appear with odd exponents.
- $6 = 2 \cdot 3$ fails because $3$ appears once.
Four Squares: A Surprising Universal Property
Unlike the two‑square case, the four‑square case is dramatically simpler:
- Every whole number can be written as a sum of four squares.
Examples:
- $7 = 4 + 1 + 1 + 1$
- $23 = 16 + 4 + 1 + 1$
- $0 = 0 + 0 + 0 + 0$
This universality is one of the most beautiful facts in number theory.
Lagrange’s Four‑Square Theorem
Lagrange proved in 1770:
- Every natural number $n$ can be written as $$n = a^2 + b^2 + c^2 + d^2.$$
Key ideas (informal):
- Squares grow quickly, so only a few are needed.
- Clever algebraic identities show that sums of four squares multiply nicely.
- This allows building representations for all numbers.
Visualizing Sums of Four Squares
Ways to picture four squares:
- Think of a point in 4‑dimensional space: $(a,b,c,d)$.
- The number $n$ is the squared distance from the origin: $$n = a^2 + b^2 + c^2 + d^2.$$
- Every “radius” in 4D space hits some lattice point.
This geometric viewpoint explains why four squares always suffice.
Connections to Modular Arithmetic
Modular arithmetic helps explain patterns:
- Squares modulo $4$ can only be $0$ or $1$.
- This explains why primes of the form $4k+3$ behave differently.
- Modulo $8$ also gives insight into sums of three squares (a related topic).
Historical Notes and Mathematical Personalities
- Fermat: first stated the two‑square theorem.
- Euler: provided the first proofs and identities.
- Lagrange: proved the four‑square theorem.
- Gauss: developed the theory of quadratic forms, generalizing these ideas.
These results were stepping stones toward modern number theory.
Common Misconceptions and Pitfalls
- “If $n$ is a sum of two squares, then so is $n+1$.”
- False: $4$ works, $5$ works, but $6$ does not.
- “Odd numbers cannot be sums of two squares.”
- False: $5, 13, 17$ all work.
- “Only primes matter.”
- Composite numbers require careful factorization.
Exercises
Try these to reinforce the ideas:
- Determine whether $21$ can be written as a sum of two squares. Explain why or why not.
- Find all representations of $25$ as a sum of two squares.
- Show that $45$ is a sum of two squares by finding explicit $a$ and $b$.
- Factor $117$ and decide whether it is a sum of two squares.
- Write $23$ as a sum of four squares.
- Prove that no number of the form $4k+3$ can be written as $a^2 + b^2$ when $k$ is small (try $k=0,1,2$).
- Find a number that is a sum of four squares but not a sum of two squares.
- Explore: How many ways can $50$ be written as a sum of two squares?